package com.zwh.rabbitmq.config;

/**
 * 是与否enum
 */
public enum BooleanEnum {
    /**
     * 否：0
     */
    NO("0", "否"),
    /**
     * 是：1
     */
    YES("1", "是");

    private final String id;
    private final String name;

    /**
     * @param id          id
     * @param displayName 名称
     */
    BooleanEnum(String id, String displayName) {
        this.id = id;
        this.name = displayName;
    }

    public static BooleanEnum parseEnumById(String staus) {
        for (BooleanEnum enm : BooleanEnum.values()) {
            if (BooleanEnum.YES.getId().equals(staus)) {
                return enm;
            }
        }
        return BooleanEnum.NO;
    }

    public static boolean parseById(String status) {
        return YES.getId().equals(status)? true : false;
    }

    public static String parseByStatus(boolean status) {
        return status ? YES.getId() : NO.getId();
    }

    public String getId() {
        return id;
    }

    public String getName() {
        return name;
    }
}
